package com.gsm.controller;

import com.gsm.entity.Result;
import com.gsm.po.RotationChart;
import com.gsm.service.RotationChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轮播图(RotationChart)表控制层
 *
 * @author wjq
 * @since 2020-12-03 06:13:58
 */
@RestController
@RequestMapping("rotationChart")
public class RotationChartController {
    @Autowired
    private RotationChartService rotationChartService;

    /**
     * 新增
     */
    @PostMapping("rotationChart")
    public Result insertRotationChart(@RequestBody RotationChart rotationChart) {
        Result result = rotationChartService.insertRotationChart(rotationChart);
        return result;
    }

    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("rotationChart/{chartId}")
    public Result deleteRotationChartByChartId(@PathVariable("chartId") Long chartId) {
        Result result = rotationChartService.deleteRotationChartByChartId(chartId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("rotationChart/{chartId}")
    public Result updateRotationChartByChartId(@PathVariable("chartId") Long chartId, @RequestBody RotationChart rotationChart) {
        rotationChart.setChartId(chartId);
        Result result = rotationChartService.updateRotationChartByChartId(rotationChart);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("rotationChart/{chartId}")
    public Result selectRotationChartByChartId(@PathVariable("chartId") Long chartId) {
        Result result = rotationChartService.selectRotationChartByChartId(chartId);
        return result;
    }

    /**
     * 根据条件查询 List
     */
    @GetMapping("rotationChartList")
    public Result selectRotationChartList(RotationChart rotationChart) {
        Result result = rotationChartService.selectRotationChartList(rotationChart);
        return result;
    }

    /**
     * 根据id排序
     */
    @PutMapping("order")
    public Result updateChartShowOrder(@RequestBody List<Long> ids) {
        Result result = rotationChartService.updateChartShowOrder(ids);
        return result;
    }
}